#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>

using namespace std;

int countPrimes(int n) {
    vector<int> prime;
    vector<bool> st(n + 1);
    for (int i = 2; i < n; i++)
    {
        if (!st[i])
            prime.push_back(i);
        for (int j = 0; prime[j] <= n / i; j++)
        {
            st[prime[j] * i] = true;
            if (i % prime[j] == 0)   break;
        }
    }

    return prime.size();
}